package com.kai.utils;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

public class JsonUtils {
    private static ObjectMapper mapper= new ObjectMapper();

    /**
     * 对象转换成json字符串
     * @param o
     * @return
     */
    public static String objectToString(Object o){
        String s="";
        try {
            s = mapper.writeValueAsString(o);
            return s;
        } catch (JsonProcessingException e) {
            e.printStackTrace();
        }
        return s;
    }
}
